﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RailwayReservationWeb.master
{
    public partial class Manager : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // var authsvc = new AuthService();
            try
            {
                if (Session["authinfo"] == null)
                {
                    Response.Redirect("~/manager/login.aspx");
                }
                else
                {
                    var authinfo = (Account)Session["authinfo"];
                    if (authinfo.Role < 2)
                    {
                        Response.Redirect("~/manager/login.aspx");
                    }
                    const string gravatarRoot = "http://www.gravatar.com/avatar/";
                    string emailHash = Checksum.MD5(authinfo.Email.Trim());
                    imgProfile.ImageUrl = gravatarRoot + emailHash;
                    loginFullName.InnerText = authinfo.FullName;
                    loginUserName.InnerText = authinfo.UserName;
                }
            }
            catch (Exception) { }
        }
    }
}